package Server.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * Entity - 商品订单
 *
 * @author xvzhe
 * @version 0.1
 *
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
public class ShopOrder {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name="NumberIdProduce", strategy="Server.tool.NumberIdProduce")
    private String uuid;


    /*
     *
     * 用户
     *
     * */
    @ManyToOne
    @JoinColumn(name = "userId")
    private  Users users;

    @Column(columnDefinition="int default 1")
    private Integer count;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @CreatedDate
    @Column
    private Date createTime;
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @LastModifiedDate
    @Column
    private Date modifiedTime;
    /*
     *
     * 应付款金额
     *
     * */
    @Column(columnDefinition="int default 0")
    private BigDecimal incomeMoney;

    /*
    *
    * 付款金额
    *
    * */
    @Column(columnDefinition="int default 0")
    private BigDecimal money;


    /*
     *
     * 城市减免金额
     *
     * */
    @Column(columnDefinition="int default 0")
    private BigDecimal cityMoney;

    /*
    *
    * 优惠折扣
    *
    *
    * */
    @Column(columnDefinition="int default 0")
    private BigDecimal saleMoney;


    /*
     *
     * 优惠折扣
     *
     *
     * */
    @Column(columnDefinition="int default 0")
    private BigDecimal annul ;

    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public enum Status {
        NO("未付款"),
        YES("已付款"),
        MAIL("邮寄中"),
        END("已收货"),
        CALL("取消"),
        QUIT("退货");
        Status(String display) {
            this.display = display;
        }
        private String display;

        public String getDisplay() {
            return display;
        }

        public void setDisplay(String display) {
            this.display = display;
        }
    }
    @Enumerated(EnumType.STRING)
    @Column
    private Status status;


    @ManyToOne
    @JoinColumn(name = "siteId")
    private  UserSite userSite;

    @Lob
    @Column
    private String note;

    /*
    *
    * 邮寄方式
    *
    * */
    @ManyToOne
    @JoinColumn(name = "dictId")
    private Diction diction;

    /*
    *
    * 快递单号
    *
    * */
    @Column
    private String nio;

    /*
    *
    * 用户留言
    *
    * */
    @Lob
    @Column
    private String spack;

    public BigDecimal getIncomeMoney() {
        return incomeMoney;
    }

    public void setIncomeMoney(BigDecimal incomeMoney) {
        this.incomeMoney = incomeMoney;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public Users getUsers() {
        return users;
    }

    public void setUsers(Users users) {
        this.users = users;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifiedTime() {
        return modifiedTime;
    }

    public void setModifiedTime(Date modifiedTime) {
        this.modifiedTime = modifiedTime;
    }

    public BigDecimal getMoney() {
        return money;
    }

    public void setMoney(BigDecimal money) {
        this.money = money;
    }

    public BigDecimal getSaleMoney() {
        return saleMoney;
    }

    public void setSaleMoney(BigDecimal saleMoney) {
        this.saleMoney = saleMoney;
    }


    public UserSite getUserSite() {
        return userSite;
    }

    public void setUserSite(UserSite userSite) {
        this.userSite = userSite;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public Diction getDiction() {
        return diction;
    }

    public void setDiction(Diction diction) {
        this.diction = diction;
    }

    public String getSpack() {
        return spack;
    }

    public void setSpack(String spack) {
        this.spack = spack;
    }

    public String getNio() {
        return nio;
    }

    public void setNio(String nio) {
        this.nio = nio;
    }

    public BigDecimal getCityMoney() {
        return cityMoney;
    }

    public void setCityMoney(BigDecimal cityMoney) {
        this.cityMoney = cityMoney;
    }

    public BigDecimal getAnnul() {
        return annul;
    }

    public void setAnnul(BigDecimal annul) {
        this.annul = annul;
    }
}
